package cn.hhy.org.mapper;

import cn.hhy.org.domain.Shop;
import cn.hhy.org.query.ShopQuery;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface ShopMapper {


    List<Shop> shopLoadAll(ShopQuery shopQuery);

    Long findShopCountByQuery(ShopQuery shopQuery);
    /**
     * 查询全部
     * @return
     */

    @Select("select * from t_shop")
    List<Shop> loadAll();
    /**
     * 新增
     * @param shop
     */
    @Insert("insert into t_shop (name, tel, registerTime, state, address, admin_id)\n" +
            "    values (#{name}," +
            "            #{tel}," +
            "            #{registerTime}," +
            "            #{state}," +
            "            #{address}," +
            "            #{employee.id});")
    void save(Shop shop);

    /**
     * 修改
     * @param shop
     */
    @Update("update t_shop set name=#{name}, tel=#{tel} ," +
            "registerTime=#{registerTime},state=#{state},address=#{address}," +
            "admin_id=#{employee.id}" +
            " where id=#{id};")
    void update(Shop shop);

    /**
     * 删除
     * @param id
     */
    @Delete( "delete from t_shop where id=#{id}")
    void delete(Long id);

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Select("select * from t_shop where id=#{id}")
    Shop loadById(Long id);

    void PatchDelete(Long[] ids);


}
